import java.util.*;

public class Activity {

    private String id;
    private String name;
    private Date startTime;
    private Date endTime;
    private String description;
    private String site;

    List<Teacher> teachers = new ArrayList<>();
    List<Team> teams = new ArrayList<>();
    List<Organizer> organizers = new ArrayList<>();

    public Activity(String id, String name, Date startTime, Date endTime, String description, String site) {
        this.id = id;
        this.name = name;
        this.startTime = startTime;
        this.endTime = endTime;
        this.description = description;
        this.site = site;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public Date getStartTime() {
        return startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public String getDescription() {
        return description;
    }

    public String getSite() {
        return site;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void addTeamToActivity(Team team){
        this.teams.add(team);
    }

    public void removeTeamFromActivity(String id){
        Iterator<Team> iterator = teams.iterator();
        while (iterator.hasNext()){
            Team next = iterator.next();
            if(next.getTeamId().equals(id)){
                iterator.remove();
            }
        }
    }

    public void addTeacherToActivity(Teacher teacher){
        this.teachers.add(teacher);
    }

    public void removeTeacherFromActivity(String id){
        Iterator<Teacher> iterator = teachers.iterator();
        while (iterator.hasNext()){
            Teacher next = iterator.next();
            if(next.getId().equals(id)){
                iterator.remove();
            }
        }
    }

    public void addOrganizerToActivity(Organizer organizer){
        this.organizers.add(organizer);
    }

    public void removeOrganizerFromActivity(String id){
        Iterator<Organizer> iterator = organizers.iterator();
        while (iterator.hasNext()){
            Organizer next = iterator.next();
            if(next.getId().equals(id)){
                iterator.remove();
            }
        }
    }

    @Override
    public String toString() {
        StringBuilder activity = new StringBuilder();
        activity.append("Acitivity{").
                append("id='").append(id).
                append(", name=").append(name).
                append(", startTime='").append(startTime).
                append(", endTime='").append(endTime).
                append(", description=").append(description).
                append(", site=").append(site).
                append(", teachers=").append(teachers.toString()).
                append(", teams=").append(teams.toString()).
                append(", organizers=").append(organizers.toString()).append("'}");
        return activity.toString();

    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Activity activity = (Activity) o;
        return id.equals(activity.id) && name.equals(activity.name) && startTime.equals(activity.startTime) && endTime.equals(activity.endTime) && description.equals(activity.description) && site.equals(activity.site) && teachers.equals(activity.teachers) && teams.equals(activity.teams) && organizers.equals(activity.organizers);
    }

}
